package linkedlist.test160;

import listbyorder.utils.ListNode;

import java.util.Random;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/7/14 13:53
 */
public class Solution1 {

    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        if (headA == null || headB == null) return null;
        ListNode a = headA, b = headB;
        while (a != b) {
            a = a == null ? headB : a.next;
            b = b == null ? headA : b.next;
        }
        return a;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            test();
        }
    }

    public static void test(){
        Random random = new Random();
        int n = random.nextInt(10);
        System.out.printf(String.valueOf(n));
    }
}
